"""
Test runner script
Used to resolve module import issues and run user module tests
"""

import sys
import os
import subprocess

# Get project root directory
project_root = os.path.dirname(os.path.abspath(__file__))
gt_lms_path = os.path.join(project_root, 'gt_lms')

# Set PYTHONPATH environment variable
env = os.environ.copy()
env['PYTHONPATH'] = project_root + os.pathsep + gt_lms_path

# Run tests
if __name__ == "__main__":
    # Run pytest in project root directory
    result = subprocess.run([
        sys.executable, '-m', 'pytest', 'gt_lms/tests/test_user.py', '-v'
    ], capture_output=True, text=True, env=env, cwd=project_root)
    
    # Output results
    print("STDOUT:")
    print(result.stdout)
    print("\nSTDERR:")
    print(result.stderr)
    print(f"\nExit code: {result.returncode}")